package com.yc.jiushujie.jsj_order.mapper;

import com.yc.jiushujie.entity.JsjBook;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.jiushujie.entity.JsjUser;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 无罪
 * @since 2022-08-03
 */
public interface JsjBookMapper extends BaseMapper<JsjBook> {
    //    @Select("select * from jsj_book b join"+
//            " jsj_user u on u.id=b.owner_id" +
//            " where b.id=#{bid}"
//           )
//    List<JsjUser> selectBYBid(@Param("bid") int bid);
    @Select("select * from jsj_book"+
            " where id=#{id}")
    @Results({
            @Result(property = "ownerId", column = "owner_id"),
            @Result(property = "user", column = "owner_id",
                    many = @Many(select = "selectUser"))
    })
    JsjBook selectBook(int id);

    @Select("select * from jsj_user where id=#{ownerId}")
    JsjUser selectUser(int id);
@Select("SELECT\n" +
        "\tcount(*) cnt\n" +
        "FROM\n" +
        "\tjsj_book\n")
   Map<String, Object> selectCount();
@Select("SELECT\n" +
        "\t*\n" +
        "FROM\n" +
        "\tjsj_book\n" +
        "LIMIT #{page},#{size}")
List<JsjBook>selectAllBook(@Param("page") int page,@Param("size") int size);
}
